﻿<UserControl x:Class="BestsellerHistory.Page"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    d:DesignWidth="400" d:DesignHeight="300" 
    xmlns:nyt="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" xmlns:nytvc="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit">
	<UserControl.Resources>
		<nyt:BestsellerHistory x:Key="BestsellerHistoryDS" Title="Outliers" 
                               d:IsDataSource="True" />
        <nytvc:InverterConverter x:Key="InverterConverter"/>
	</UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition/>
    	</Grid.RowDefinitions>
        <chartingToolkit:Chart Grid.Row="1">
            <chartingToolkit:LineSeries
        ItemsSource="{Binding Mode=OneWay, Path=RankHistory, Source={StaticResource BestsellerHistoryDS}}"
        DependentValueBinding="{Binding Rank, Converter={StaticResource InverterConverter}}"
        IndependentValuePath="BestsellersDate"
        Title="Rank">
                <chartingToolkit:LineSeries.DataPointStyle>
                    <Style TargetType="chartingToolkit:LineDataPoint">
                        <Setter Property="DependentValueStringFormat" Value="{}{0:0.#;0.#}"/>
                    </Style>
                </chartingToolkit:LineSeries.DataPointStyle>
                <chartingToolkit:LineSeries.DependentRangeAxis>
                    <chartingToolkit:LinearAxis
                Orientation="Y"
                Minimum="-20"
                Maximum="-1"
                Interval="1"
                ShowGridLines="False">
                        <chartingToolkit:LinearAxis.AxisLabelStyle>
                            <Style TargetType="chartingToolkit:AxisLabel">
                                <Setter Property="StringFormat" Value="{}{0:0.#;0.#}"/>
                            </Style>
                        </chartingToolkit:LinearAxis.AxisLabelStyle>
                    </chartingToolkit:LinearAxis>
                </chartingToolkit:LineSeries.DependentRangeAxis>
            </chartingToolkit:LineSeries>
        </chartingToolkit:Chart>
    	<StackPanel Orientation="Horizontal" Margin="4">
    		<TextBlock Height="Auto" Text="Title" Width="Auto" VerticalAlignment="Center"/>
    		<TextBox Text="{Binding Mode=TwoWay, Path=Title, Source={StaticResource BestsellerHistoryDS}}" 
                     Margin="5,0,0,0" Width="207"/>
    		<Button Content="Search Bestseller History"/>
    	</StackPanel>
    </Grid>
</UserControl>
